From: Florian Müllner Date: Sun, 26 Feb 2017 13:55:48 +0000 (+0100) Subject: unlockDialog: Show media notifications on lock screen X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~112^2^2~4 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=49566feb4457f9f61ebb9d8769d98a42575cb53b;p=gnome-shell.git unlockDialog: Show media notifications on lock screen While we have included a built-in media section in the calendar for a while, it is currently only available when the session is unlocked. The ability to quickly pause or resume media playback directly from the lock screen is quite handy though, so start showing them alongside the existing screen shield notifications. Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/488 Part-of: --- diff --git a/js/ui/unlockDialog.js b/js/ui/unlockDialog.js index 77e80571e..fae4d0787 100644 --- a/js/ui/unlockDialog.js +++ b/js/ui/unlockDialog.js @@ -16,6 +16,8 @@ import * as MessageTray from './messageTray.js'; import * as SwipeTracker from './swipeTracker.js'; import {formatDateWithCFormatString} from '../misc/dateUtils.js'; import * as AuthPrompt from '../gdm/authPrompt.js'; +import {MprisSource} from './mpris.js'; +import {MediaMessage} from './messageList.js'; // The timeout before going back automatically to the lock screen (in seconds) const IDLE_TIMEOUT = 2 * 60; @@ -49,6 +51,16 @@ const NotificationsBox = GObject.registerClass({ }); this.add_child(this._scrollView); + this._players = new Map(); + this._mediaSource = new MprisSource(); + this._mediaSource.connectObject( + 'player-added', (o, player) => this._addPlayer(player), + 'player-removed', (o, player) => this._removePlayer(player), + this); + this._mediaSource.players.forEach(player => { + this._addPlayer(player); + }); + this._settings = new Gio.Settings({ schema_id: 'org.gnome.desktop.notifications', }); @@ -69,6 +81,9 @@ const NotificationsBox = GObject.registerClass({ let items = this._sources.entries(); for (let [source, obj] of items) this._removeSource(source, obj); + + for (const player of this._players.keys()) + this._removePlayer(player); } _updateVisibility() { @@ -202,6 +217,20 @@ const NotificationsBox = GObject.registerClass({ this.emit('wake-up-screen'); } + _addPlayer(player) { + const message = new MediaMessage(player); + this._players.set(player, message); + this._notificationBox.insert_child_at_index(message, 0); + this._updateVisibility(); + } + + _removePlayer(player) { + const message = this._players.get(player); + this._players.delete(player); + message.destroy(); + this._updateVisibility(); + } + _sourceAdded(tray, source, initial) { let obj = { visible: source.policy.showInLockScreen, @@ -217,7 +246,7 @@ const NotificationsBox = GObject.registerClass({ x_expand: true, }); this._showSource(source, obj, obj.sourceBox); - this._notificationBox.add_child(obj.sourceBox); + this._notificationBox.insert_child_at_index(obj.sourceBox, this._players.size); source.connectObject( 'notify::count', () => this._countChanged(source, obj),